//
//  LKDeseaseIMGCell.m
//  QuickCure
//
//  Created by 胡不归是大虾 on 9/12/16.
//  Copyright © 2016 haoge. All rights reserved.
//

#import "LKDeseaseIMGCell.h"
@interface LKDeseaseIMGCell( )
@property(nonatomic,weak) UILabel* titleLabel;

@property(nonatomic,weak) UIButton* deseaseImageBtn;


@end
@implementation LKDeseaseIMGCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpMyUI];
    }
    return self;
}
-(void) setUpMyUI
{
    UILabel* titleLabel = [[UILabel alloc] init];
    self.titleLabel = titleLabel;
    [self.contentView addSubview: titleLabel];
    //设置约束
    [titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentView).offset(15);
    }];
    titleLabel.text = @"病例照片";
    UIButton* deseaseImageBtn = [[UIButton alloc] init];
    self.deseaseImageBtn = deseaseImageBtn;
    [self.contentView addSubview:deseaseImageBtn];
    self.deseaseImageBtn.adjustsImageWhenDisabled = NO;
    //按钮添加点击方法
    [deseaseImageBtn addTarget:self action:@selector(didClickImageBtn) forControlEvents:UIControlEventTouchUpInside];
    //设置约束
    [deseaseImageBtn makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel).offset(30);
        make.left.equalTo(self.contentView).offset(50);
        make.width.height.equalTo(70);
    }];
    [self.deseaseImageBtn setBackgroundImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
}

-(void) didClickImageBtn
{
    if (_addImageBlock) {
        _addImageBlock();
    }

}


//重写图片的setter方法
-(void)setCaseImage:(UIImage *)caseImage
{
    _caseImage = caseImage;
    [self.deseaseImageBtn setBackgroundImage:caseImage forState:UIControlStateNormal];
}


@end
